package com.iot.web.controller.device;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iot.common.annotation.Log;
import com.iot.common.core.controller.BaseController;
import com.iot.common.core.domain.AjaxResult;
import com.iot.common.enums.BusinessType;
import com.iot.device.domain.BeidouClient;
import com.iot.device.service.IBeidouClientService;
import com.iot.common.utils.poi.ExcelUtil;
import com.iot.common.core.page.TableDataInfo;

/**
 * 海岛北斗设备Controller
 * 
 * @author iot
 * @date 2023-05-10
 */
@RestController
@RequestMapping("/device/beidouClient")
public class BeidouClientController extends BaseController
{
    @Autowired
    private IBeidouClientService beidouClientService;

    /**
     * 查询海岛北斗设备列表
     */
    @PreAuthorize("@ss.hasPermi('device:beidouClient:list')")
    @GetMapping("/list")
    public TableDataInfo list(BeidouClient beidouClient)
    {
        startPage();
        List<BeidouClient> list = beidouClientService.selectBeidouClientList(beidouClient);
        return getDataTable(list);
    }

    /**
     * 导出海岛北斗设备列表
     */
    @PreAuthorize("@ss.hasPermi('device:beidouClient:export')")
    @Log(title = "海岛北斗设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BeidouClient beidouClient)
    {
        List<BeidouClient> list = beidouClientService.selectBeidouClientList(beidouClient);
        ExcelUtil<BeidouClient> util = new ExcelUtil<BeidouClient>(BeidouClient.class);
        util.exportExcel(response, list, "海岛北斗设备数据");
    }

    /**
     * 获取海岛北斗设备详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:beidouClient:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(beidouClientService.selectBeidouClientById(id));
    }

    /**
     * 新增海岛北斗设备
     */
    @PreAuthorize("@ss.hasPermi('device:beidouClient:add')")
    @Log(title = "海岛北斗设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BeidouClient beidouClient)
    {
        return toAjax(beidouClientService.insertBeidouClient(beidouClient));
    }

    /**
     * 修改海岛北斗设备
     */
    @PreAuthorize("@ss.hasPermi('device:beidouClient:edit')")
    @Log(title = "海岛北斗设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BeidouClient beidouClient)
    {
        return toAjax(beidouClientService.updateBeidouClient(beidouClient));
    }

    /**
     * 删除海岛北斗设备
     */
    @PreAuthorize("@ss.hasPermi('device:beidouClient:remove')")
    @Log(title = "海岛北斗设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(beidouClientService.deleteBeidouClientByIds(ids));
    }
}
